<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        /* 
            Number 对象
        */
        /* 数值分隔符 */
        let budget = 1_000_000_000;
        console.log(budget === 10 ** 9, budget === 10_000_000_00, budget);

        /* EPSILION */
        Number.EPSILON === Math.pow(2. - 52); //true
        console.log(0.1 + 0.2, 0.1 + 0.2 === 0.3);
        // 误差检查函数
        function withinErrorMargin(left, right) {
            return Math.abs(left - right) < Number.EPSILON * Math.pow(2, 2);
        }
        console.log(withinErrorMargin(0.1 + 0.2, 0.3));

        /* 新增属性和方法 */
        // ParseInt ParseFloat 封装到Number上, 不用全局调用
        let num = 123;
        console.log(Number.isFinite(num));
        console.log(Number.isNaN('123'));
        console.log(Number.isSafeInteger(num));

        console.log('--------------');

        /* 
            新数据类型 - BigInt
        */
       const a = 123n;
       let b = 123;
       console.log(a == b, a === b, typeof a);
       console.log(a === BigInt(b));
    </script>
</body>

</html>